<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd">  
<html > 
<head><title>English POS Tagging</title> 
<meta http-equiv="Content-Type" content="text/html; charset=gbk"> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> 
<!-- html --> 
<meta name="src" content="eng_tagger.tex"> 
<meta name="date" content="2013-03-28 00:53:00"> 
<link rel="stylesheet" type="text/css" href="eng_tagger.css"> 
</head><body 
>
   <div class="maketitle">
                                                                          

                                                                          
                                                                          

                                                                          

<h2 class="titleHead">English POS Tagging</h2>
<div class="author" ></div><br />
<div class="date" ><span 
class="ptmr7t-x-x-144">March 28, 2013</span></div>
   </div>
   <h3 class="sectionHead"><span class="titlemark">1    </span> <a 
 id="x1-10001"></a>How to compile</h3>
<!--l. 15--><p class="noindent" >Suppose that ZPar has been downloaded to the directory <span 
class="ptmri7t-x-x-120">zpar</span>. To make a POS tagging
system for English, type <span 
class="ptmri7t-x-x-120">make english.postagger</span>. This will create a directory
<span 
class="ptmri7t-x-x-120">zpar/dist/english.postagger</span>, in which there are two files: <span 
class="ptmri7t-x-x-120">train </span>and <span 
class="ptmri7t-x-x-120">tagger</span>. The file <span 
class="ptmri7t-x-x-120">train</span>
is used to train a tagging model,and the file <span 
class="ptmri7t-x-x-120">tagger </span>is used to tag new texts using a
trained parsing model.
   <h3 class="sectionHead"><span class="titlemark">2    </span> <a 
 id="x1-20002"></a>Format of inputs and outputs</h3>
<!--l. 17--><p class="noindent" >The input files to the <span 
class="ptmri7t-x-x-120">tagger </span>executable are formatted as a sequence of tokenized
English sentences. An example input is: <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             Ms. Haag plays Elianti . <br 
class="newline" /><br 
class="newline" />The output files contain space-separated words: <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             Ms./NNP Haag/NNP plays/VBZ Elianti/NNP ./. <br 
class="newline" /><br 
class="newline" />The output format is also the format of training files for the <span 
class="ptmri7t-x-x-120">train </span>executable.
   <h3 class="sectionHead"><span class="titlemark">3    </span> <a 
 id="x1-30003"></a>How to train a model</h3>
<!--l. 31--><p class="noindent" >To train a model, use <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             zpar/dist/english.postagger/train <span 
class="cmmi-12">&#x003C;</span>train-file<span 
class="cmmi-12">&#x003E; &#x003C;</span>model-file<span 
class="cmmi-12">&#x003E;</span>
<span 
class="cmmi-12">&#x003C;</span>number of iterations<span 
class="cmmi-12">&#x003E; </span><br 
class="newline" /><br 
class="newline" />For example, using the <a 
href="eng_pos_files/train.txt" >example train file</a>, you can train a model by <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                              zpar/dist/english.postagger/train train.txt model 1
<br 
class="newline" /><br 
class="newline" />After training is completed, a new file <span 
class="ptmri7t-x-x-120">model </span>will be created in the current
directory, which can be used to assign POS tags to tokenized sentences. The above
command performs training with one iteration (see Section&#x00A0;<a 
href="#x1-60006">6<!--tex4ht:ref: tuning --></a>) using the training
file.
   <h3 class="sectionHead"><span class="titlemark">4    </span> <a 
 id="x1-40004"></a>How to tag new texts</h3>
<!--l. 43--><p class="noindent" >To apply an existing model to tag new texts, use <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             zpar/dist/english.postagger/tagger <span 
class="cmmi-12">&#x003C;</span>model<span 
class="cmmi-12">&#x003E; &#x003C;</span>input-file<span 
class="cmmi-12">&#x003E;</span>
<span 
class="cmmi-12">&#x003C;</span>output-file<span 
class="cmmi-12">&#x003E; </span><br 
class="newline" /><br 
class="newline" />For example, using the model we just trained, we can tag <a 
href="eng_pos_files/input.txt" >an example input</a> by
<br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             zpar/dist/english.postagger/tagger model input.txt output.txt
<br 
class="newline" /><br 
class="newline" />The output file contains automatically tagged sentences.
                                                                          

                                                                          
   <h3 class="sectionHead"><span class="titlemark">5    </span> <a 
 id="x1-50005"></a>Outputs and evaluation</h3>
<!--l. 57--><p class="noindent" >Automatically tagged texts contain errors. In order to evaluate the quality of the outputs,
we can manually specify the POS tags of a sample, and compare the outputs with the
correct sample. <br 
class="newline" />Manually specified POS tags of the input file are given in <a 
href="eng_pos_files/reference.txt" >this example reference file</a>.
Here is a <a 
href="eng_pos_files/evaluate.py" >Python script</a> that performs automatic evaluation. <br 
class="newline" /><br 
class="newline" />Using the above <span 
class="ptmri7t-x-x-120">output.txt </span>and <span 
class="ptmri7t-x-x-120">reference.txt</span>, we can evaluate the accuracies by typing
<br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             python evaluate.py output.txt reference.txt <br 
class="newline" /><br 
class="newline" />The output of the evaluation script is a single number: <span 
class="ptmri7t-x-x-120">per-token accuracy </span>which is
defined to be the ratio of correctly POS-tagged words over all the words in
output.txt.
   <h3 class="sectionHead"><span class="titlemark">6    </span> <a 
 id="x1-60006"></a>How to tune the performance of a system</h3>
<!--l. 71--><p class="noindent" >The performance of the system after one training iteration may not be optimal. You can
try training a model for another few iterations, after each you compare the performance.
You can choose the model that gives the highest f-score on your test data. We
conventionally call this test file the development test data, because you develop
a parsing model using this. Here is a <a 
href="eng_pos_files/test.sh" >a shell script</a> that automatically trains
the POS tagger for 30 iterations, and after the <span 
class="cmmi-12">i</span>th iteration, stores the model
file to model.<span 
class="cmmi-12">i</span>. You can compare the f-score of all 30 iterations and choose
model.<span 
class="cmmi-12">k</span>, which gives the best f-score, as the final model. In this file, this is a
variable called <span 
class="ptmri7t-x-x-120">zpar</span>. You need to set this variable to the relative directory of
<span 
class="ptmri7t-x-x-120">zpar/dist/english.postagger</span>.
   <h3 class="sectionHead"><span class="titlemark">7    </span> <a 
 id="x1-70007"></a>Source code</h3>
<!--l. 73--><p class="noindent" >The source code for the English POS tagger can be found at <br 
class="newline" /><br 
class="newline" />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;                             zpar/src/common/tagger/implementation/ENGLISH_TAGGER_IMPL
<br 
class="newline" /><br 
class="newline" />where ENGLISH_TAGGER_IMPL is a macro defined in <span 
class="ptmri7t-x-x-120">Makefile</span>, and specifies a
specific implementation for the English POS tagger.
 
</body></html> 

                                                                          


